﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Drawing;

namespace Curves
{
    public class ScarabaeusCurve : Curve
    {
        [Category("Shape")]
        [Description("changes the value for a in r(θ) = cos (2θ) - a cos (θ)")]
        public float A
        {
            get { return a; }
            set { a = value; }
        }
        private float a = 0;

        [Category("Shape")]
        public Point Origin
        {
            get { return origin; }
            set { origin = value; }
        }
        private Point origin = new Point(240, 240);

        [Category("Shape")]
        public float Scale
        {
            get { return scale; }
            set { scale = value; }
        }
        private float scale = 100;

        public ScarabaeusCurve()
        {
            samples = 100;
        }
        // Draws the actual Scarabaeus Curve
        public override PointF[] GetCurve()
        {
            PointF[] curve = new PointF[samples + 1];
            //
            double dt = 2.0 * Math.PI / samples;
            double t = 0.0;
            for (int i = 0; i <= samples; i++)
            {
                float x = Origin.X + scale * ( (float)Math.Cos(t) * ( (float)Math.Cos(2 * t) - a * (float)Math.Cos(t) ) );
                float y = Origin.Y + scale * ( (float)Math.Sin(t) * ( (float)Math.Cos(2 * t) - a * (float)Math.Cos(t) ) );
                curve[i] = new PointF(x, y);
                //
                t += dt;
            }
            //
            return curve;
        }
    }
}
